package com.fcscs.ecms.dao.hibernate;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.fcscs.core.dao.ConnectionManager;
import com.fcscs.core.domain.BaseEntity.DBLoc;
import com.fcscs.ecms.dao.ECMSGuestRequestAwuDao;
import com.fcscs.ecms.domain.GuestRequestAwu;

/**
 * @author pvttinh
 * 
 */

@SuppressWarnings("unchecked")
@Repository("guestRequestAwuDao")
public class ECMSGuestRequestAwuDaoHibernate implements ECMSGuestRequestAwuDao {
	
	@Autowired
	private ConnectionManager connMgr;
	
	@Override
	public GuestRequestAwu get(int guestRequestId) throws Exception {
		// TODO Auto-generated method stub
		GuestRequestAwu gra= null;
		try{
			gra = (GuestRequestAwu) this.connMgr.getCurrentSession(DBLoc.GUEST).get(GuestRequestAwu.class, guestRequestId);
			if(null == gra){
				throw new Exception("GUEST REQUEST AWU NOT EXIST");
			}
		}
		catch (Exception e) {
			// TODO: handle exception
			throw new Exception("GuestRequestAwu.DAO.get() - " + e.getMessage());
		}
		
		return gra;
	}
	
	@Override
	public GuestRequestAwu update(GuestRequestAwu gra) throws Exception {
		// TODO Auto-generated method stub
		try{
			this.connMgr.getCurrentSession(DBLoc.GUEST).update(gra);
		}catch (Exception e) {
			// TODO: handle exception
			throw new Exception("GuestRequestAwu.DAO.update() - " + e.getMessage());
		}				
		
		return gra;
	}
}
